package com.lw.test.aop;

import org.springframework.http.HttpStatus;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

/** @author LiuWang */
//@RestControllerAdvice
public class GlobalExceptionHandler {

  @ExceptionHandler({BindException.class, MethodArgumentNotValidException.class})
  @ResponseStatus(HttpStatus.OK)
  public R handle(Exception e) {
    return R.builder().msg("参数校验失败").data(e.getMessage()).build();
  }
}
